All Questions
56 questions
0votes
3answers
283views
awk/sed in loop to replace numbers (with result of computation)
I am relatively new to awk and sed. I have a file with more than 30000 rows/lines; e.g., Direct configuration= 5 0.86331344 0.14835363 0.01770155 0.83813858 0.74789354 0.31772038 0.89805721 0....
1vote
4answers
143views
Remove duplicates by adding numerical suffix
How do I append a numerical suffix to lines to remove duplicates? Pseudo code: if currLine.startsWith("tag:") x = numFutureLinesMatching(currLine) if (x > 0) currLine = currLine + ...
0votes
3answers
484views
How do I use grep, awk, or sed to get a substring of a line up until a string literal?
I am trying to process a text file and omit a certain string literal if it occurs at the end of the line. E.g.: Source: ABC 123 DEF, characters I don't want GHI, these characters are ok Desired ...
1vote
2answers
43views
Remove all function documentation matching a pattern from a file
Let's say you have many functions with auto-generated documentation similar to: /** * @author John Doe */ Is there a simple way to remove these 3 lines from every function documented this way in ...
0votes
3answers
687views
compare multiple files in bash script
bash and shell programming is new for me.I have a few files with the extension .v.gz, in the bash command I am performing some operations, and ill store the result in the same filename with .txt ...
-2votes
1answer
47views
Can this be done with sed?
I wrote a simple python program to do some text processing. I wanted to split sentences into lines with sed, using the text from a screenplay/stage play as input. I tried to write it in sed, but could ...
0votes
2answers
169views
awk - Processing a file without Header into a csv with the format header,record1,record2
I have a data file in the following format abcd: x:123 y:2345 pqrs: x:456 y:720 mnop: x:234 y:4567 : : How can I translate this to a CSV of the format in awk: abcd,123,2345,<userstring1>,&...
5votes
5answers
782views
How can I replace multiple substrings from multiple lines in a file matching a pattern from a different file?
I have a file that contains multiple IP addresses and hostnames, and another file that contains some folders with many IP addresses per line. ip_hostname.txt host1 10.1.1.1 host2 10.2.2.2 host3 10.3.3....
-1votes
1answer
2kviews
Bulk replace multiple variables in multiple files at once
Example: I have 40 different variables like $VAR in 100 .txt files which are located in /home/user/EXAMPLE/. How do I replace all variables in the 100 files? To tell the system what the variables are ...
3votes
2answers
344views
Find regex occurrances on block device (line length buffer issue)
I'm trying to find all numbers on two block devices that start with a # character, are between 1635700000 and 1653699999, and end either with a null character (\0) or a linux newline (\0xA). I came up ...
1vote
2answers
686views
Replace a column in file with look up table from another file
I have a tab delimited file with a column that has multiple values separated by comma where i wanted to replace values from a look up table Lookup_file: ID Name g_00001 g_00001 g_00002 cytA ...
-1votes
3answers
93views
Changing the place operator in a csv file
I've been editing a CSV file so I can import it into postgres. At this point I want to change the operator from column 5 to the left side of the column when the value is negative"-". When it ...
0votes
0answers
88views
Keep every process in 1 execution block in CSV handling
I asked some questions about how to handle a csv file and this result was numerous processes. Every month I get several TXT files in a Google Drive directory. I need to process, unite and load this ...
1vote
4answers
343views
Replace contents of first column which have cyclic structure
I have a file in which the first column is to be changed, for example, I have the following file (In the original file I have multiple columns but truncating the following to 2 columns, it may have ...
5votes
4answers
330views
Incrementally Swap Lines Between Two Regex Patterns in a File
I'm trying to do some text processing on a file using a bash script. The goal is to take all of the lines starting with "field:" indented under an 'attribute:' label and swap them with the ...